Calculate format string only once
authorJonas Bernoulli <jonas@bernoul.li>
Thu, 4 Aug 2022 12:05:06 +0000 (14:05 +0200)
committerJonas Bernoulli <jonas@bernoul.li>
Thu, 4 Aug 2022 12:05:06 +0000 (14:05 +0200)
which-key.el

index 19d1f9fb3d10978d14214ba3ecffc80056685b6d..d9dcf8dee9a4985bb8b42c9bbed63ff195144426 100644 (file)
@@ -1874,13 +1874,12 @@ that width."
          (col-sep-width  (which-key--max-len col-keys 1))
          (col-desc-width (which-key--max-len
                           col-keys 2 which-key-min-column-description-width))
-         (col-width      (+ 1 col-key-width col-sep-width col-desc-width)))
+         (col-width      (+ 1 col-key-width col-sep-width col-desc-width))
+        (col-format     (concat "%" (int-to-string col-key-width)
+                                 "s%s%-" (int-to-string col-desc-width) "s")))
     (cons col-width
-          (mapcar (lambda (k)
-                    (format (concat "%" (int-to-string col-key-width)
-                                    "s%s%-" (int-to-string col-desc-width) "s")
-                            (nth 0 k) (nth 1 k) (nth 2 k)))
-                  col-keys))))
+          (mapcar (lambda (k) (apply #'format col-format k))
+                 col-keys))))
 
 (defun which-key--partition-list (n list)
   "Partition LIST into N-sized sublists."